package com.emcom.gotour.mvc.view;

import java.io.Serializable;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.springframework.context.MessageSource;

import com.emcom.gotour.mvc.message.GlobalMessage;

public class GlobalView implements Comparable<Object>, Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2516237968406200225L;
	private String operation;
	private String insert;
	private String delete;
	private String update;
	private String query;
	private String inputDate;
	private String updateDate;
	public GlobalView() {
	}
	public GlobalView(HttpServletRequest request, MessageSource messageSource) {
		this.operation = GlobalMessage.Operation.value(request, messageSource);
		this.insert = GlobalMessage.Insert.value(request, messageSource);
		this.delete = GlobalMessage.Delete.value(request, messageSource);
		this.update = GlobalMessage.Update.value(request, messageSource);
		this.query = GlobalMessage.Query.value(request, messageSource);
		this.inputDate = GlobalMessage.InputDate.value(request, messageSource);
		this.updateDate = GlobalMessage.UpdateDate.value(request, messageSource);
	}
	public String getOperation() {
		return operation;
	}
	public void setOperation(String operation) {
		this.operation = operation;
	}
	public String getInsert() {
		return insert;
	}
	public void setInsert(String insert) {
		this.insert = insert;
	}
	public String getDelete() {
		return delete;
	}
	public void setDelete(String delete) {
		this.delete = delete;
	}
	public String getUpdate() {
		return update;
	}
	public void setUpdate(String update) {
		this.update = update;
	}
	public String getQuery() {
		return query;
	}
	public void setQuery(String query) {
		this.query = query;
	}
	public String getInputDate() {
		return inputDate;
	}
	public void setInputDate(String inputDate) {
		this.inputDate = inputDate;
	}
	public String getUpdateDate() {
		return updateDate;
	}
	public void setUpdateDate(String updateDate) {
		this.updateDate = updateDate;
	}
	/**
	 * @see java.lang.Comparable#compareTo(Object)
	 */
	public int compareTo(Object object) {
		GlobalView myClass = (GlobalView) object;
		return new CompareToBuilder().append(this.update, myClass.update)
				.append(this.operation, myClass.operation).append(
						this.inputDate, myClass.inputDate).append(this.query,
						myClass.query).append(this.delete, myClass.delete)
				.append(this.insert, myClass.insert).append(this.updateDate,
						myClass.updateDate).toComparison();
	}
	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof GlobalView)) {
			return false;
		}
		GlobalView rhs = (GlobalView) object;
		return new EqualsBuilder().appendSuper(super.equals(object)).append(
				this.update, rhs.update).append(this.operation, rhs.operation)
				.append(this.inputDate, rhs.inputDate).append(this.query,
						rhs.query).append(this.delete, rhs.delete).append(
						this.insert, rhs.insert).append(this.updateDate,
						rhs.updateDate).isEquals();
	}
	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-1602128597, 571818699).appendSuper(
				super.hashCode()).append(this.update).append(this.operation)
				.append(this.inputDate).append(this.query).append(this.delete)
				.append(this.insert).append(this.updateDate).toHashCode();
	}
	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this).append("query", this.query).append(
				"delete", this.delete).append("insert", this.insert).append(
				"update", this.update).append("updateDate", this.updateDate)
				.append("inputDate", this.inputDate).append("operation",
						this.operation).toString();
	}
}
